<template>
	<view class="page">
		<view class="sc-img-box ">
			<view class="sc-circle iconfont icon-tianjiazhaopian " >			</view>
			<view class="f16 ">添加投票海报</view>
		</view>
		<!-- pic end -->

		<view class="weui-cells_form margin10-t">

			<view class="weui-cell bg-white">
				<input class="weui-input" placeholder="投票标题（最多50字）" type="text">
			</view>
			<view class="weui-cell bg-white  margin10-t">
				<textarea class="weui-textarea" placeholder="编辑投票介绍" rows="4"></textarea>
			</view>
			<view class="weui-cell  bg-white  margin10-t">
				<view class="weui-cell__bd">
					<p>投票截止时间</p>
				</view>
				<view class="weui-cell__ft f14">
					<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
						<view class="uni-input">{{date}}</view>
					</picker>
				</view>
			</view>


			<a class="weui-cell weui-cell_access bg-white  margin10-t" href="javascript:;">
				<view class="weui-cell__bd">
					<p>投票选项</p>
				</view>
				<view class="weui-cell__ft f14">
					请设置</view>
			</a>
			<a class="weui-cell weui-cell_access bg-white  margin10-t" href="javascript:;">
				<view class="weui-cell__bd">
					<p>投票权限</p>
				</view>
				<view class="weui-cell__ft f14">
					公开</view>
			</a>
			<a class="weui-cell weui-cell_access bg-white  margin10-t" href="javascript:;">
				<view class="weui-cell__bd">
					<p>每人限投次数</p>
				</view>
				<view class="weui-cell__ft f14">
					1次</view>
			</a>
			<view class="weui-cell  bg-white  margin10-t">
				<view class="weui-cell__bd">
					<p>允许多选</p>
				</view>
				<view class="weui-cell__ft f14">
					<switch color="#09BB07" />
				</view>
			</view>
			<view class="weui-cell  bg-white  margin10-t">
				<view class="weui-cell__bd">
					<p>单排显示</p>
				</view>
				<view class="weui-cell__ft f14">
					<switch color="#09BB07" />
				</view>
			</view>
			<view class="weui-cell  bg-white  margin10-t">
				<view class="weui-cell__bd">
					<p>发布状态</p>
				</view>
				<view class="weui-cell__ft f14">
					<switch checked color="#09BB07" />
				</view>
			</view>
		</view>

		<view class="page-bd-15 margin10-t">
			<a href="javascript:;" class="weui-btn weui-btn_primary" id="a" style="width: auto;">提 交</a>
			<a href="javascript:;" class="weui-btn weui-btn_plain-primary" style="width: auto;">返回</a>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			const currentDate = this.getDate({
				format: true
			})
			return {
				title: 'picker',
				array: ['全国', '省级', '市级'],
				index: 0,
				date: currentDate,
				time: '12:01'
			}
		},
		computed: {
			startDate() {
				return this.getDate('start');
			},
			endDate() {
				return this.getDate('end');
			}
		},
		methods: {
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.index = e.target.value
			},
			bindDateChange: function(e) {
				this.date = e.target.value
			},
			bindTimeChange: function(e) {
				this.time = e.target.value
			},
			getDate(type) {
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();

				if (type === 'start') {
					year = year - 60;
				} else if (type === 'end') {
					year = year + 2;
				}
				month = month > 9 ? month : '0' + month;;
				day = day > 9 ? day : '0' + day;
				return `${year}-${month}-${day}`;
			}
		}
	}
</script>

<style>
	.page {
		background: #f7f7f7;
	}

	.sc-img-box {
		height: 40vw;
		background: #F1F1F1;
		color:#aaa;
		text-align: center;
		padding-top:7vw;
	}
	.sc-circle{
		background: #E0E5E8;
		width: 180upx;
		height: 180upx;
		margin: 0 auto 20upx auto; 
		border-radius: 100%;
		text-align: center;
		line-height: 180upx;
		color:#fff;
		font-size:100upx;
		
	}
</style>
